<?php get_header(); ?>

	<div id="content">

		<?php if (have_posts()) : ?>
		
		<div class="archive-title">
 	  <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
 	  <?php /* If this is a category archive */ if (is_category()) { ?>
		<h2 class="pagetitle">Archive for the &#8216;<?php single_cat_title(); ?>&#8217; Category</h2>
 	  <?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
		<h2 class="pagetitle">Posts Tagged &#8216;<?php single_tag_title(); ?>&#8217;</h2>
 	  <?php /* If this is a daily archive */ } elseif (is_day()) { ?>
		<h2 class="pagetitle">Archive for <?php the_time('F jS, Y'); ?></h2>
 	  <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
		<h2 class="pagetitle">Archive for <?php the_time('F, Y'); ?></h2>
 	  <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
		<h2 class="pagetitle">Archive for <?php the_time('Y'); ?></h2>
	  <?php /* If this is an author archive */ } elseif (is_author()) { ?>
		<h2 class="pagetitle">Author Archive <?php echo $curauth->display_name; ?></h2>
 	  <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
		<h2 class="pagetitle">Blog Archives</h2>
 	  <?php } ?>
			<?php if ( is_404() || is_category() || is_day() || is_month() ||
						is_year() || is_search() || is_paged() ) {
			?> 
			<?php /* If this is a 404 page */ if (is_404()) { ?>
			<?php /* If this is a category archive */ } elseif (is_category()) { ?>
			<p>You are currently browsing the archives for the <?php single_cat_title(''); ?> category.</p>

			<?php /* If this is a yearly archive */ } elseif (is_day()) { ?>
			<p>You are currently browsing the <a href="<?php bloginfo('url'); ?>/"><?php echo bloginfo('name'); ?></a> blog archives
			for the day <?php the_time('l, F jS, Y'); ?>.</p>

			<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
			<p>You are currently browsing the <a href="<?php bloginfo('url'); ?>/"><?php echo bloginfo('name'); ?></a> blog archives
			for <?php the_time('F, Y'); ?>.</p>

			<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
			<p>You are currently browsing the <a href="<?php bloginfo('url'); ?>/"><?php echo bloginfo('name'); ?></a> blog archives
			for the year <?php the_time('Y'); ?>.</p>

			<?php /* If this is a monthly archive */ } elseif (is_search()) { ?>
			<p>You have searched the <a href="<?php echo bloginfo('url'); ?>/"><?php echo bloginfo('name'); ?></a> blog archives
			for <strong>'<?php the_search_query(); ?>'</strong>. If you are unable to find anything in these search results, you can try one of these links.</p>

			<?php /* If this is a monthly archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
			<p>You are currently browsing the <a href="<?php echo bloginfo('url'); ?>/"><?php echo bloginfo('name'); ?></a> blog archives.</p>

			<?php } ?>
			 <?php }?>
			 </div>
			 

		<?php while (have_posts()) : the_post(); $data = get_post_meta( $post->ID, 'post-images', true ); ?>
			<div class="post" id="post-<?php the_ID(); ?>">
<?php $data = get_post_meta( $post->ID, 'post-images', true ); ?> 
<?php // if there's a single post image
 if( $data[ 'post-image-main' ] ) : ?>
				<div class="thumb-main">
				<a href="<?php the_permalink() ?>" rel="bookmark" title=""><img height="160px" width="305px" alt="" src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php echo $data[ 'post-image-main' ]; ?>&amp;h=160&amp;w=305&amp;zc=1&amp;q=100" /></a>
				</div>
<?php else: ?>
				<div class="thumb-main">
				<a href="<?php the_permalink() ?>" rel="bookmark" title=""><img height="160px" width="305px" alt="" src="<?php bloginfo('stylesheet_directory'); ?>/images/no-thumbnail-main.png" /></a>
				</div>
<?php endif; ?> 
				<div class="entry-main">
				<div class="home-title"><h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2></div>
					<?php the_content_limit(320, ""); ?>
				</div>
				<div> <!-- blank div necessary for IE6 -->
				<div class="clear-position"><div class="comment-count"><?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></div><div class="read-more"><a href="<?php the_permalink() ?>" rel="bookmark" title="Read more of <?php the_title_attribute(); ?>">Read More</a></div><div class="author"><?php the_author_posts_link(); ?></div></div>
				</div>
			</div>

		<?php endwhile; ?>

<?php if (function_exists('wp_pagenavi')) { wp_pagenavi(); } else {echo '<div class="alignleft">';posts_nav_link('','','&laquo; Previous Entries'); echo '</div><div class="alignright">';posts_nav_link('','Next Entries &raquo;',''); echo '</div>'; } ?>

	<?php else : ?>

		<h2 class="center">Nothing Found</h2>
		<p class="center">Sorry, but you are looking for something that isn't here. Search our Archives!</p>
		<br />
<form id="searchform" method="get" action="<?php bloginfo('home'); ?>/"> <input type="text"  size="18" maxlength="50" name="s" id="s" /> 
<input name="submit" type="image" src="<?php bloginfo('stylesheet_directory'); ?>/images/go.png" value="Search" Title="Search" class="search-button"/></form> 
<div class="clear">&nbsp;</div>

	<?php endif; ?>

	</div>

<?php get_sidebar(); ?>

<?php get_footer(); ?>
